package common

type Result struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

// 相应枚举值
const (
	DataIsNull      int = 1
	SUCCESS         int = 2
	UserNotExist    int = 3
	UserIsExists    int = 4
	PasswordError   int = 5
	LoginTimeOut    int = 6
	HasNoAuthorized int = 7
)

func GetResult(num int) Result {
	switch num {
	case DataIsNull:
		return Result{Code: 00000, Msg: "数据为空", Data: nil}
	case SUCCESS:
		return Result{Code: 10000, Msg: "响应成功", Data: nil}
	case UserNotExist:
		return Result{Code: 50004, Msg: "用户不存在或未授权使用", Data: nil}
	case UserIsExists:
		return Result{Code: 50004, Msg: "用户已存在", Data: nil}
	case PasswordError:
		return Result{Code: 50004, Msg: "用户名或密码错误", Data: nil}
	case LoginTimeOut:
		return Result{Code: 50003, Msg: "登陆超时或无法使用系统", Data: nil}
	case HasNoAuthorized:
		return Result{Code: 50004, Msg: "用户权限不足", Data: nil}
	default:
		return Result{Code: -99999, Msg: "服务器内部错误", Data: nil}
	}
}
